﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace subtitle_modifier
{
    class ConfigFile
    {
        private static ConfigFile instance;
        private static XmlDocument cofigFileXml;

        public static XmlDocument CofigFileXml
        {
            get { return cofigFileXml; }
            set { cofigFileXml = value; }
        }
   private ConfigFile() {}

   public static ConfigFile Instance
   {
      get 
      {
         if (instance == null)
         {
            instance = new ConfigFile();
            intConfigFile();
         }
         return instance;
      }
   }

   private static void intConfigFile()
   {
       CofigFileXml = new XmlDocument();
       CofigFileXml.Load("config.xml");

   }

   /// <summary>
   /// This method get to text only from propertyName(string propertyName) in the Reposetoriy node
   /// </summary>
   /// 
   public string getPropertyFromReposetoriy(string propertyName)
   {
       string property = "";
       XmlElement root = CofigFileXml.DocumentElement;
       XmlNode node = root.SelectSingleNode("reposetoriy");
       property = node[propertyName].InnerText;
       return property;
 
   }
   /// <summary>
   /// This method set the text only in propertyName(string propertyName) in the Reposetoriy node
   /// </summary>
   /// 
   public void setPropertyToReposetoriy(string propertyName, string thePropertyToInsert)
   {
       string property = "";
       XmlElement root = CofigFileXml.DocumentElement;
       XmlNode node = root.SelectSingleNode("reposetoriy");
       node[propertyName].InnerText = thePropertyToInsert;
       CofigFileXml.Save("config.xml");
       //return property;

   }



    }
}
